package mid

func WateringPlants(plants []int, capacity int) int {
	step := 0
	total := capacity
	for i, num := range plants {
		if capacity >= num {
			step++
			capacity -= num
		} else {
			step += 2*i + 1
			capacity = total - num
		}
	}
	return step
}
